<!--
  #%L
  thinkbig-ui-feed-manager
  %%
  Copyright (C) 2017 ThinkBig Analytics
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  #L%
  -->
<div class="md-padding">

            <div ng-if="vm.loadingHiveSchemas">
                <span class="hint">初始化自动填充数据</span>
            <md-progress-linear md-mode="indeterminate" ></md-progress-linear>
            </div>
            <div id="hqlEditorContainer">
                <span class="md-input-label">输入查询</span>
                <div class="hql-editor" ui-codemirror ng-model="vm.sql" ui-codemirror-opts="vm.codemirrorOptions">
                </div>
            </div>
                <span class="hint">{{vm.metadataMessage}}</span>
<div layout="row" layout-fill layout-align="space-between center">
            <md-button class="md-primary md-raised" ng-disabled="vm.sql == ''" ng-click="vm.query()" ng-if="vm.allowExecuteQuery">
                执行查询
            </md-button>
    <span flex></span>
    <md-button ng-if="vm.allowFullscreen" class="md-raised" ng-if="vm.mode != 'fullscreen'" ng-click="vm.fullscreen()" >
        全屏
    </md-button>
</div>
              <div ng-if="vm.allowDatabaseBrowse" class="layout-padding-top">
                <div class="md-title">浏览 Hive</div>
                <md-input-container>
                    <label>数据库</label>
                    <md-select ng-model="vm.browseDatabaseName" >
                        <md-option ng-repeat="databaseName in vm.databaseNames" value="{{::databaseName}}">
                            {{::databaseName}}
                        </md-option>
                    </md-select>
                </md-input-container>
                <md-input-container>
                    <label>表</label>
                    <md-select ng-model="vm.browseTableName" ng-change="vm.browseTable()" >
                        <md-option ng-repeat="(tableName,fields) in vm.databaseMetadata[vm.browseDatabaseName]" value="{{::tableName}}">
                            {{::tableName}}
                        </md-option>
                    </md-select>
                </md-input-container>
                </div>
            <md-progress-linear md-mode="indeterminate" ng-if="vm.executingQuery"></md-progress-linear>
                <div class="browse-results" ng-if="vm.queryResults.columns && vm.queryResults.rows.length >0">

                    <div ui-grid-auto-resize  style="width:100%;height:500px;"
                         ui-grid="vm.gridOptions"
                            ></div>
                    </div>
</div>
